package com.ids.transfer;

import java.util.HashMap;
import java.util.Map;

import com.ids.transfer.config.Constant;
import com.ids.transfer.data.XmlParse;

/**
 * Extra-data Factory Class
 */
public class ExtraFactory {
	//延迟加载
	protected static Map classMap = new HashMap();

	/**
	 * 
	 * @param key
	 * @return
	 */
	public static Object createEtra(String key) {
		try {
			String className = (String) classMap.get(key);
			if (className != null) {
				Class clas = Class.forName(className);
				return clas.newInstance();
			} else {
				//动态装载
				HashMap<String, Object> hm = XmlParse
						.getImpClassInfo(Constant.XMLFILEPATH, key);
				className = (String) hm.get("type");
				if (className != null) {
					Class clas = Class.forName(className);
					classMap.put(key, className);
					return clas.newInstance();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}


}